package DATABASE;
//classe que conecta o JAVA ao BD
import java.sql.*;

/**
 * 
 * @author Programador
 */
public class ConnectionManager {

	private static Connection con = null;

        /**
         * 
         * @return
         * @throws SQLException
         */
        public static Statement getStatement() throws SQLException {
		if(con==null) {
	      String url = "jdbc:mysql://localhost:3306/sicer";
	      System.out.println(url);
	      try {
                  Class.forName("org.gjt.mm.mysql.Driver");
	          con = DriverManager.getConnection(url,"root", "");
	          //Display URL and connection information
	      } catch (Exception e) {
	    	  System.out.println("Erro de Conexão\n"+e.getMessage());
	    	  System.exit(1);
	      }
		}
		return con.createStatement();
	}

        /**
         * 
         */
        public static void closeConnection() {
		try {
			con.close();
		} catch (SQLException e) {}
		con = null;
	}
}